home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / PROGNG_C / CUG187.LZH / UTOA.C < prev    next >
Text File  |  1985-12-31  |  1KB  |  31 lines

  1. /*@*****************************************************/
  2. /*@                                                    */
  3. /*@ utoa - convert unsigned integer to ascii.          */
  4. /*@        Very useful to prevent loading of printf    */
  5. /*@        and the 2-8K of follow-ons.                 */
  6. /*@                                                    */
  7. /*@   Usage:     utoa(num, buffer);                    */
  8. /*@       where num is an unsigned integer.            */
  9. /*@             buffer is a char area large enough to  */
  10. /*@                to hold the resulting string.       */
  11. /*@                                                    */
  12. /*@   Returns a pointer to the buffer.  This allows    */
  13. /*@       nesting of puts(utoa(n, buffer)); variety.   */
  14. /*@                                                    */
  15. /*@*****************************************************/
  16.  
  17. utoa(n,s)        /* convert n to characters in s */
  18. char s[];
  19. unsigned n;
  20. {
  21.     int i;
  22.  
  23.     i = 0;
  24.     do {                /* generate digits in reverse order */
  25.         s[i++] = n % 10 + '0';          /* get next digit */
  26.     } while ((n /= 10) > 0);        /* delete it */
  27.     s[i] = '\0';
  28.     reverse(s);
  29.     return s;
  30. }
  31.